#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>
#include <climits>

using namespace std;


struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

class Solution {
public:
	int min(int a, int b){
		return (a > b ? b : a);
	}
	int minDepth(TreeNode *root) {
		if (root == NULL) return 0;
		TreeNode* leftChild = root->left;
		TreeNode* rightChild = root->right;
		if (leftChild == NULL && rightChild == NULL)
			return 1;
		else if (leftChild == NULL){
			return 1 + minDepth(rightChild);
		}
		else if (rightChild == NULL){
			return 1 + minDepth(leftChild);
		}
		else{
			return 1 + min(minDepth(leftChild), minDepth(rightChild));
		} 
	}
};
int main(int argc, char argv){

	return 0;
}